/**
 * 
 */
package com.youth.fund.hk.hostManager.manager.dao.mybatis;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.youth.fund.hk.hostManager.common.Constants;
import com.youth.fund.hk.hostManager.common.dao.mybatis.BaseMybatisDao;
import com.youth.fund.hk.hostManager.manager.dao.RelatedProductDao;
import com.youth.fund.hk.hostManager.manager.datamodel.RelatedProductModel;

/**
 * @author Sunk_Sky
 *
 * 2014年12月1日上午10:09:57
 */
@Repository("RelatedProductDao")
public class RelatedProductMybatisDaoImpl extends BaseMybatisDao<RelatedProductModel, Integer> implements RelatedProductDao
{
	private final static String CREATE_ZH_CN = "related_zh_cn.create";

	private final static String DELETE_ZH_CN = "related_zh_cn.delete";

	private final static String UPDATE_ZH_CN = "related_zh_cn.update";

	private final static String QUERY_BY_CONDITION_ZH_CN = "related_zh_cn.list_by_condition";
	
	private final static String CREATE_ZH_HK = "related_zh_hk.create";

	private final static String DELETE_ZH_HK = "related_zh_hk.delete";

	private final static String UPDATE_ZH_HK = "related_zh_hk.update";

	private final static String QUERY_BY_CONDITION_ZH_HK = "related_zh_hk.list_by_condition";
	
	private final static String CREATE_EN = "related_en.create";

	private final static String DELETE_EN = "related_en.delete";

	private final static String UPDATE_EN = "related_en.update";

	private final static String QUERY_BY_CONDITION_EN = "related_en.list_by_condition";
	
	
	@Override
	public boolean create(RelatedProductModel model)
	{
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());

		model.setSetup_time(timestamp);

		model.setUpdate_time(timestamp);
		
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.create(model, CREATE_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.create(model, CREATE_ZH_CN);
		}else
		{
			return super.create(model, CREATE_ZH_HK);
		}
	}

	@Override
	public boolean delete(RelatedProductModel model)
	{
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.delete(model, DELETE_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.delete(model, DELETE_ZH_CN);
		}else
		{
			return super.delete(model, DELETE_ZH_HK);
		}
	}

	@Override
	public boolean update(RelatedProductModel model)
	{
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());

		model.setUpdate_time(timestamp);
		
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.update(model, UPDATE_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.update(model, UPDATE_ZH_CN);
		}else
		{
			return super.update(model, UPDATE_ZH_HK);
		}
	}

	@Override
	public List<RelatedProductModel> query(RelatedProductModel model)
	{
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.query(model, QUERY_BY_CONDITION_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.query(model, QUERY_BY_CONDITION_ZH_CN);
		}else
		{
			return super.query(model, QUERY_BY_CONDITION_ZH_HK);
		}
	}

	@Override
	public RelatedProductModel queryOne(RelatedProductModel model)
	{
		if(Constants.LANG_EN.equalsIgnoreCase(model.getLang()))
		{
			return super.queryOne(model, QUERY_BY_CONDITION_EN);
		}else if(Constants.LANG_ZH_CN.equalsIgnoreCase(model.getLang()))
		{
			return super.queryOne(model, QUERY_BY_CONDITION_ZH_CN);
		}else
		{
			return super.queryOne(model, QUERY_BY_CONDITION_ZH_HK);
		}
	}
	
}
